/**
 * Copyright 2016 vip.com.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 * </p>
 **/

package spring.cloud.tasks.api.database.service;

import org.springframework.data.domain.Pageable;
import spring.cloud.tasks.api.database.entity.TaskConfigurationDto;

import java.util.List;
import java.util.Map;

public interface TaskConfigurationDtoService {

    int create(TaskConfigurationDto currentJobConfig) throws RuntimeException;

    int deleteByPrimaryKey(Long id) throws RuntimeException;

    int updateByPrimaryKey(TaskConfigurationDto currentJobConfig) throws RuntimeException;

    void batchUpdatePreferList(List<TaskConfigurationDto> jobConfigs) throws RuntimeException;

    List<TaskConfigurationDto> getTaskConfigurationDtoListByNamespace(String namespace) throws RuntimeException;

    List<TaskConfigurationDto> getTaskConfigurationDtoListByNamespaceWithCondition(String namespace, Map<String, Object> condition,
                                                                                   Pageable pageable) throws RuntimeException;

    int countTaskConfigurationDtoByNamespaceWithCondition(String namespace, Map<String, Object> condition)
            throws RuntimeException;

    int countEnabledUnSystemJobsByNamespace(String namespace) throws RuntimeException;

    TaskConfigurationDto getTaskConfigurationDtoByNameSpaceAndTaskId(String namespace, String jobName) throws RuntimeException;

    List<String> findConfigNamesByNameSpace(String namespace) throws RuntimeException;

    void updateNewAndSaveOld2History(final TaskConfigurationDto newJobConfig, final TaskConfigurationDto oldJobConfig,
                                     final String userName) throws RuntimeException;


    /**
     * 查找具有有效作业的域名列表
     */
    List<String> findHasValidJobNamespaces(String jobType, int isEnabled);

    /**
     * 查找有效作业的cron配置
     */
    List<TaskConfigurationDto> findValidJobsCronConfig();
}